<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:atom="http://www.w3.org/2005/Atom"
      xmlns:gh="http://a9.com/-/spec/opensearchrss/1.0/"
      xmlns:n1="urn:astm-org:CCR"
      exclude-result-prefixes="xs"
      version="2.0">
        <xsl:output method="xml"/>

    <xsl:template match="/">
        <n1:Medications xmlns:n1="urn:astm-org:CCR">
            <xsl:apply-templates select="/atom:feed"/>
        </n1:Medications>    
    </xsl:template>
        <xsl:template match="/atom:feed">
                <xsl:apply-templates select="atom:entry"/>
        </xsl:template>
    
        <xsl:template match="atom:entry">
            <xsl:if test="child::atom:category[@term='MEDICATION']">
                <xsl:apply-templates select="n1:ContinuityOfCareRecord"/>
            </xsl:if>
        </xsl:template>
        
        <xsl:template match="n1:ContinuityOfCareRecord">
            <xsl:copy-of select="n1:Body/n1:Medications/n1:Medication"/>
        </xsl:template>
</xsl:stylesheet>
